package com.allenjsl.springactuator.rocketmq;

import org.apache.rocketmq.client.producer.MessageQueueSelector;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;

import java.util.List;

public class OrderMessageQueueSelector implements MessageQueueSelector {
    @Override
    public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
        //选择以参数arg为索引的MessageQueue
        Integer id = (Integer) arg;
        int index = id % mqs.size();
        return mqs.get(index);
    }
}
